//
//  LoginApi.m
//  gamebox_qpp
//
//  Created by 赵隆杰 on 2022/1/6.
//

#import "LoginApi.h"

@implementation LoginApi{
    NSString *_userName;
    NSString *_passWord;
    NSString *_appleId;
}

- (instancetype)initWithUserName:(NSString *)userName passWord:(NSString *)passWord
{
    if (self = [super init])
    {
        _userName = userName;
        _passWord = passWord;
    }
    
    return self;
}

- (instancetype)initWithAppleId:(NSString *)appleId
{
    if (self = [super init])
    {
        _appleId = appleId;
    }
    
    return self;
}

- (NSString *)requestUrl {
    if (_appleId.length) {
        return [NSString stringWithFormat:@"user/appleLogin/%@", _appleId];
    }
    return @"user/login";
}

- (YTKRequestMethod)requestMethod {
    return YTKRequestMethodPOST;
}

- (id)requestArgument {
    
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    if (_appleId.length) {
        params[@"appleId"] = _appleId;
    } else {
        params[@"userName"] = _userName;
        params[@"passWord"] = _passWord;
    }
    
    return params;
}

@end
